﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.AnalysisServices;
using System.Configuration;

namespace ParallelCubeProcessor
{
    public class CubeProcessingThread
    {
        private string _serverName;

        public CubeProcessingThread(string ServerName)
        {
            _serverName = ServerName;
        }

        public void Start(object Data)
        {
            RealStart((Database)Data);
        }

        public void RealStart(Database DB)
        {
            System.Console.WriteLine(string.Format("[{0}] Processing {1}", DateTime.Now.ToLongTimeString(), DB.Name));
            
            Server server = new Server();
            server.Connect(_serverName);
            server.Databases.GetByName(DB.Name).Process(ProcessType.ProcessFull);
            server.Disconnect();
            
            System.Console.WriteLine(string.Format("[{0}] Completed Processing {1}", DateTime.Now.ToLongTimeString(), DB.Name));
        }
    }
}
